<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: huajie <banhuajie@163.com>
// +----------------------------------------------------------------------

namespace Admin\Controller;
use Admin\model\AuthGroupModel;
use COM\Page;
/**
 * 后台内容控制器
 * @author huajie <banhuajie@163.com>
 */

class Leaveword1Controller extends \Admin\Controller\AdminController {
      private  $status=array(1=>'留言提交',2=>'已回复',3=>'留言无效');
      function index(){
         //@header("Content-type: text/html; charset=utf8");
         // echo 'aaaa';
       // $list = M('document')->select();
       // var_dump($list);
        //$Leaveword = D('Leaveword');
      $list = M('leaveword1 lw')
          //->table ('onethink_levaeword lw')
          ->field ('lw.id,lw.name,lw.mobile,lw.title,lw.ctime,lw.type2,lt.name tname')
          ->order('lw.id desc')
          ->join('onethink_leaveword1 lt ON lw.type=lt.id')->select();
          //$list = $this->lists($Leaveword);
          $this->assign('status',$this->status);
          $this->assign('list',$list);
          $this->display(); }
    function add(){
               //echo 'aaaaa';
            $data=D('Leaveword1')->select();
            $this->assign('data',$data);
            $this->display();
      }
      function save(){      	 
          
              $data = I();

              $data['ctime'] = time();
              //var_dump($data);exit;
              $res = D('Leaveword1')->update($data);
              if(!res){
                   $this->success('添加成功！',U('index'));
              }else{
                   $this->success('更新成功！',U('index'));
              }
	  }
		  
	function delete(){
            $id = $_GET['id'];

            // dump($id);
            $res = D('Leaveword1')->delete($id);

            $this->success('删除成功',U('index'));


	}
	function modify(){

            $id = I('get.id');//$_POST['id'];
            $Leaveword = D('Leaveword1');
            //$sql = "select * from where "
            $a = $Leaveword->find($id);
            // var_dump($a);die();
            $this->assign('a',$a);
            $this->display();
	}
		  
	/* function save(){	 

      	  $data = I();

          $data['ctime'] = time();
          //var_dump($data);exit;
          $res = D('Leaveword')->update($data);
          if(!res){
                  $this->error(D('Leaveword')->getError());
              }else{
              	if($res)['id']{
               $this->success('添加成功！',U('index'));
          }else{
               $this->success('更新成功！',U('index'));
               }
            }
        }
        */
       function detail(){
                $id = I('get.id');//$_POST['id'];
                $Leaveword1 = D('Leaveword1');
                //$sql = "select * from where "
                $a = $Leaveword1->find($id);
                // var_dump($a);die();
                $this->assign('a',$a);
                $this->display();
	}
 }